package com.only4play.authcenter.infrastructure.convert;

/**
 * @author hinzzz www.hinzzz.cn 157957329@qq.com
 * 2024-03-07
 */
import com.only4play.authcenter.constants.AuthType;

import javax.persistence.AttributeConverter;

public class AuthTypeConverter implements AttributeConverter<AuthType,Integer> {

  @Override
  public Integer convertToDatabaseColumn(AuthType authType) {
    return authType.getCode();
  }

  @Override
  public AuthType convertToEntityAttribute(Integer code) {
    return AuthType.of(code).orElse(null);
  }
}
